package io.zerax.moyu_chat;

import android.app.*;
import android.os.*;
import android.view.View;
import android.content.Intent;
import android.widget.EditText;
import android.widget.Toast;

public class LoginActivity extends Activity 
{
    public EditText id;
    @Override
    protected void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.login);
        
        id = findViewById(R.id.id_input);

        
        setTitle(getString(R.string.app_name) + " - Login");
    }
    
    public void onOkClick(View v) {
        String idVal = id.getEditableText().toString();
        if (idVal.isEmpty() || idVal.length() >= 20) {
            Toast.makeText(this, R.string.id_restriction, Toast.LENGTH_SHORT).show();
            return;
        }
        
        Intent intent = new Intent(this, MainActivity.class);
        intent.putExtra("chat_name", idVal);
        startActivity(intent);
    }
}
